define(["angularAMD", 'moment'], function (angularAMD, moment) {
    angularAMD.service('$ClosItem', ['$rootScope', '$filter', '$translate', 'config', 'MMWService', '$mdDialog',
        function($rootScope, $filter, $translate, config, $MMWService, $mdDialog){
            var service = this;

            service.init = function(options){
                (function openDialog(){
                    $mdDialog.dialog(
                        'module/moduleSMT/program/SMT26/closeItem.tmp.html',
                        function (dialog) {
                            return {
                                title:$filter('translate')('SMT26.close_reason'),
                                reason_info:options.reason_info,
                                reason:'',
                                back:function(){
                                    dialog.hide();
                                },
                                confirm: function () {
                                    let content = {
                                        picklist_id:dialog.reason_info.picklist_id,
                                        close_reason:dialog.reason
                                    }
                                    $MMWService.sendToServer({
                                        uri: 'ServicesSMT.Module_SMT.stock_pick_close_process',
                                        content,
                                        success: function (data) {
                                            options.pick_list.splice(options.key,1);//除去項目
                                            dialog.hide();
                                        }
                                    });
                                }
                            }
                        }
                    );
                })();
            };
        }
    ]);
});
